home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10305 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  969 b 

  1. Path: garden.csc.calpoly.edu!not-for-mail
  2. From: dstubbs@garden.csc.calpoly.edu (Dan Stubbs)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: String Question
  5. Date: 16 Mar 1996 09:58:40 -0800
  6. Organization: Cal Poly, San Luis Obispo
  7. Message-ID: <4ievgg$qcg@garden.csc.calpoly.edu>
  8. References: <DoBt0E.4A9@freenet.carleton.ca>
  9. NNTP-Posting-User: dstubbs@garden.csc.calpoly.edu
  10.  
  11. In article <DoBt0E.4A9@freenet.carleton.ca>,
  12. Jerry Boyd <aq436@FreeNet.Carleton.CA> wrote:
  13. >
  14. >How would I write a function to remove a specified
  15. >number of characters from a string and store it in an array.
  16. >For instance, extracting three characters from a string, starting
  17. >from the 5th character.
  18. >
  19. >
  20.  
  21. void remove (char A[], char B[], int p, int q, int n) {
  22. /*
  23.  * Delete p characters from A beginning with the qth character.
  24.  * Copy the deleted characters to B. Assume that A starts with
  25.  * n characters and that n >= (p+q) - 1.
  26.  */
  27.    memcpy  (B, A+q-1, p);
  28.    memmove (A+q-1, A+q+p-1, n-(p+q)+1);
  29. }
  30.  
  31.